﻿#region zh-CHS 2006 - 2007 DemoSoft 团队 | en 2006 - 2007 DemoSoft Team

//     NOTES
// ---------------
//
// This file is a part of the MMOSE(Massively Multiplayer Online Server Engine) for .NET.
//
//                              2006-2007 DemoSoft Team
//
//
// First Version : by H.Q.Cai - mailto:caihuanqing@hotmail.com

/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as published
 *   by the Free Software Foundation; either version 2.1 of the License, or
 *   (at your option) any later version.
 *
 ***************************************************************************/

#region zh-CHS 包含名字空间 | en Include namespace
using System;
using System.Text;
using System.Threading;
using System.Diagnostics;
using System.Collections.Generic;
using Demo.Mmose.Core.Util;
using Demo.Mmose.Core.Item;
using Demo.Mmose.Core.World;
using Demo.Mmose.Core.Common;
using Demo.Mmose.Core.Network;
using Demo.Mmose.Core.Creature;
using Demo.Mmose.Core.Character;
using Demo.Mmose.Core.Common.Collections;
#endregion

namespace Demo.Mmose.Core.Map
{
    /// <summary>
    /// 地图内某个部分的内容及信息(Clients,Mobiles,Items)
    /// </summary>
    public class MapSpaceNode
    {
        #region zh-CHS 私有常量 | en Private Constants
        /// <summary>
        /// 
        /// </summary>
        internal const int DICTIONARY_CAPACITY_SIZE = 20;
        #endregion

        #region zh-CHS 构造和初始化和清理 | en Constructors and Initializers and Dispose
        /// <summary>
        /// 
        /// </summary>
        /// <param name="owner"></param>
        public MapSpaceNode( BaseMap owner )
        {
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="owner"></param>
        public MapSpaceNode( Rectangle3D partitionSpaceRectangle, BaseMap owner )
        {
            m_SpaceNodeRectangle = partitionSpaceRectangle;
            m_Owner = owner;
        }
        #endregion

        #region zh-CHS 共有属性 | en Public Properties

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private Rectangle3D m_SpaceNodeRectangle = new Rectangle3D();
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public Rectangle3D SpaceNodeRectangle
        {
            get { return m_SpaceNodeRectangle; }
            set { m_SpaceNodeRectangle = value; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 地图的全部地图点的数据
        /// </summary>
        private MapSpaceNode[, ,] m_SpaceNodes = null;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public MapSpaceNode[, ,] SpaceNodes
        {
            get { return m_SpaceNodes; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private RankIndex m_RankIndex = new RankIndex();
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public RankIndex RankIndex
        {
            get { return m_RankIndex; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private int m_LayerIndex = 0;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public int LayerIndex
        {
            get { return m_LayerIndex; }
        }
        
        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private SpaceNodeState m_SpaceNodeState = SpaceNodeState.Deactivate;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public SpaceNodeState SpaceNodeState
        {
            get { return m_SpaceNodeState; }
            set { m_SpaceNodeState = value; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private bool m_IsLeaf = true;
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public bool IsLeaf
        {
            get { return m_IsLeaf; }
            internal set { m_IsLeaf = value; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 可填充得扩展数据
        /// </summary>
        private object m_ExtendData = null;
        #endregion
        /// <summary>
        /// 可填充得扩展数据
        /// </summary>
        public object ExtendData
        {
            get { return m_ExtendData; }
            set { m_ExtendData = value; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private MapSpaceNode m_ParentSpaceNode = null;
        #endregion
        /// <summary>
        /// 当前的区域点如果有玩家的话就激活该区域点(true)
        /// 如果没有玩家的话，无效此区域点(false)
        /// </summary>
        public MapSpaceNode Parent
        {
            get { return m_ParentSpaceNode; }
            internal set { m_ParentSpaceNode = value; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 拥有者的地图
        /// </summary>
        private BaseMap m_Owner = null;
        #endregion
        /// <summary>
        /// 地图点的拥有者(地图)
        /// </summary>
        public BaseMap Owner
        {
            get { return m_Owner; }
            internal set { m_Owner = value; }
        }

        #region zh-CHS Creature 属性 | en Creature Properties
        /// <summary>
        /// 地图点内的所有人物(npc/playes/monster)数量
        /// </summary>
        public long CreaturesCount
        {
            get { return m_Creatures.Count; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 怪物/NPC的列表
        /// </summary>
        private SafeDictionary<BaseCreature, BaseCreature> m_Creatures = new SafeDictionary<BaseCreature, BaseCreature>( DICTIONARY_CAPACITY_SIZE );
        #endregion
        /// <summary>
        /// 地图点内的所有人物(npc/monster)数组
        /// </summary>
        /// <returns></returns>
        public BaseCreature[] CreaturesToArray()
        {
            return m_Creatures.ToArrayValues();
        }
        #endregion

        #region zh-CHS Items 属性 | en Items Properties
        /// <summary>
        /// 地图点内的所有道具数量
        /// </summary>
        public long ItemsCount
        {
            get { return m_Items.Count; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 道具的列表
        /// </summary>
        private SafeDictionary<BaseItem, BaseItem> m_Items = new SafeDictionary<BaseItem, BaseItem>( DICTIONARY_CAPACITY_SIZE );
        #endregion
        /// <summary>
        /// 地图点内的所有道具数组
        /// </summary>
        /// <returns></returns>
        public BaseItem[] ItemsToArray()
        {
            return m_Items.ToArrayValues();
        }
        #endregion

        #region zh-CHS Players 属性 | en Players Properties
        /// <summary>
        /// 地图点内的所有玩家数量(playes)
        /// </summary>
        public long PlayersCount
        {
            get { return m_Players.Count; }
        }

        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 地图点内的所有玩家
        /// </summary>
        private SafeDictionary<BaseCharacter, BaseCharacter> m_Players = new SafeDictionary<BaseCharacter, BaseCharacter>( DICTIONARY_CAPACITY_SIZE );
        #endregion
        /// <summary>
        /// 地图点内所有的玩家数组
        /// </summary>
        /// <returns></returns>
        public BaseCharacter[] PlayersToArray()
        {
            return m_Players.ToArrayValues();
        }
        #endregion

        #endregion

        #region zh-CHS 共有方法 | en Public Methods

        #region zh-CHS 分割区域点 | en
        /// <summary>
        /// 
        /// </summary>
        public virtual void ProcessPartitionSpace( IPartitionSpaceNode partitionSpaceInterface )
        {
            if ( partitionSpaceInterface == null )
            {
                Debug.WriteLine( "BaseMap.ProcessPartitionSpace(...) - partitionSpaceInterface == null error!" );
                return;
            }

            this.ThreadPartitionSpaceNode += new EventHandler<PartitionSpaceNodeEventArgs>( partitionSpaceInterface.ProcessPartitionSpaceNode );
            this.ThreadActivateSpaceNode += new EventHandler<ActivateSpaceNodeEventArgs>( partitionSpaceInterface.ActivateSpaceNode );
            this.ThreadDeactivateSpaceNode += new EventHandler<DeactivateSpaceNodeEventArgs>( partitionSpaceInterface.DeactivateSpaceNode );

            EventHandler<PartitionSpaceNodeEventArgs> tempEventArgs = m_ThreadEventPartitionSpaceNode;
            if ( tempEventArgs != null )
            {
                PartitionSpaceNodeEventArgs eventArgs = new PartitionSpaceNodeEventArgs( this, this.m_Owner );
                tempEventArgs( this, eventArgs );

                if ( eventArgs.PartitionSpace != null )
                {
                    m_SpaceNodes = eventArgs.PartitionSpace;

                    for ( int iIndex0 = 0; iIndex0 < m_SpaceNodes.GetLength( 0 ); iIndex0++ )
                    {
                        for ( int iIndex1 = 0; iIndex1 < m_SpaceNodes.GetLength( 1 ); iIndex1++ )
                        {
                            for ( int iIndex2 = 0; iIndex2 < m_SpaceNodes.GetLength( 2 ); iIndex2++ )
                            {
                                if ( m_SpaceNodes[iIndex0, iIndex1, iIndex2] != null )
                                {
                                    m_SpaceNodes[iIndex0, iIndex1, iIndex2].RankIndex.Rank0Index = iIndex0;
                                    m_SpaceNodes[iIndex0, iIndex1, iIndex2].RankIndex.Rank1Index = iIndex1;
                                    m_SpaceNodes[iIndex0, iIndex1, iIndex2].RankIndex.Rank2Index = iIndex2;

                                    m_SpaceNodes[iIndex0, iIndex1, iIndex2].Parent = this;
                                    m_SpaceNodes[iIndex0, iIndex1, iIndex2].Owner = this.Owner;
                                    m_SpaceNodes[iIndex0, iIndex1, iIndex2].m_LayerIndex = this.m_LayerIndex + 1;

                                    m_SpaceNodes[iIndex0, iIndex1, iIndex2].ProcessPartitionSpace( partitionSpaceInterface );
                                }
                            }
                        }
                    }

                    m_IsLeaf = false;
                }
            }
        }
        #endregion

        #region zh-CHS 进入或离开区域点 | en
        /// <summary>
        /// 
        /// </summary>
        /// <param name="baseItem"></param>
        public void OnEnter( BaseItem baseItem )
        {
            m_Items.Add( baseItem, baseItem );

            EventHandler<ItemEnterSpaceNodeEventArgs> tempEventArgs = m_ThreadEventItemEnterSpaceNode;
            if ( tempEventArgs != null )
            {
                ItemEnterSpaceNodeEventArgs eventArgs = new ItemEnterSpaceNodeEventArgs( baseItem, this );
                tempEventArgs( this, eventArgs );
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="baseItem"></param>
        public void OnLeave( BaseItem baseItem )
        {
            m_Items.Remove( baseItem );

            EventHandler<ItemLeaveSpaceNodeEventArgs> tempEventArgs = m_ThreadEventItemLeaveSpaceNode;
            if ( tempEventArgs != null )
            {
                ItemLeaveSpaceNodeEventArgs eventArgs = new ItemLeaveSpaceNodeEventArgs( baseItem, this );
                tempEventArgs( this, eventArgs );
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="baseMobile"></param>
        public void OnEnter( BaseCreature baseCreature )
        {
            m_Creatures.Add( baseCreature, baseCreature );

            EventHandler<CreatureEnterSpaceNodeEventArgs> tempEventArgs = m_ThreadEventCreatureEnterSpaceNode;
            if ( tempEventArgs != null )
            {
                CreatureEnterSpaceNodeEventArgs eventArgs = new CreatureEnterSpaceNodeEventArgs( baseCreature, this );
                tempEventArgs( this, eventArgs );
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="baseMobile"></param>
        public void OnLeave( BaseCreature baseCreature )
        {
            m_Creatures.Remove( baseCreature );

            EventHandler<CreatureLeaveSpaceNodeEventArgs> tempEventArgs = m_ThreadEventCreatureLeaveSpaceNode;
            if ( tempEventArgs != null )
            {
                CreatureLeaveSpaceNodeEventArgs eventArgs = new CreatureLeaveSpaceNodeEventArgs( baseCreature, this );
                tempEventArgs( this, eventArgs );
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="baseMobile"></param>
        public void OnEnter( BaseCharacter baseCharacter )
        {
            m_Players.Add( baseCharacter, baseCharacter );

            EventHandler<CharacterEnterSpaceNodeEventArgs> tempEventArgs = m_ThreadEventCharacterEnterSpaceNode;
            if ( tempEventArgs != null )
            {
                CharacterEnterSpaceNodeEventArgs eventArgs = new CharacterEnterSpaceNodeEventArgs( baseCharacter, this );
                tempEventArgs( this, eventArgs );
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="baseMobile"></param>
        public void OnLeave( BaseCharacter baseCharacter )
        {
            m_Players.Remove( baseCharacter );

            EventHandler<CharacterLeaveSpaceNodeEventArgs> tempEventArgs = m_ThreadEventCharacterLeaveSpaceNode;
            if ( tempEventArgs != null )
            {
                CharacterLeaveSpaceNodeEventArgs eventArgs = new CharacterLeaveSpaceNodeEventArgs( baseCharacter, this );
                tempEventArgs( this, eventArgs );
            }
        }
        #endregion

        #region zh-CHS 激活/无效区域点 | en
        /// <summary>
        /// 
        /// </summary>
        public virtual void OnActivate()
        {
            EventHandler<ActivateSpaceNodeEventArgs> tempEventArgs = m_ThreadEventActivateSpaceNode;
            if ( tempEventArgs != null )
            {
                ActivateSpaceNodeEventArgs eventArgs = new ActivateSpaceNodeEventArgs( this );
                tempEventArgs( this, eventArgs );
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public virtual void OnDeactivate()
        {
            EventHandler<DeactivateSpaceNodeEventArgs> tempEventArgs = m_ThreadEventDeactivateSpaceNode;
            if ( tempEventArgs != null )
            {
                DeactivateSpaceNodeEventArgs eventArgs = new DeactivateSpaceNodeEventArgs( this );
                tempEventArgs( this, eventArgs );
            }
        }
        #endregion

        #endregion

        #region zh-CHS 私有事件 | en Private Event

        #region zh-CHS PartitionSpaceNode事件 | en Public Event
        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private EventHandler<PartitionSpaceNodeEventArgs> m_ThreadEventPartitionSpaceNode;
        /// <summary>
        /// 
        /// </summary>
        private ReaderWriterLockSlim m_LockThreadEventPartitionSpaceNode = new ReaderWriterLockSlim();
        #endregion
        /// <summary>
        /// 
        /// </summary>
        private event EventHandler<PartitionSpaceNodeEventArgs> ThreadPartitionSpaceNode
        {
            add
            {
                ReaderWriterLockSlimEx.EnterWriteLock( m_LockThreadEventPartitionSpaceNode );
                {
                    m_ThreadEventPartitionSpaceNode += value;
                }
                ReaderWriterLockSlimEx.ExitWriteLock( m_LockThreadEventPartitionSpaceNode );
            }
            remove
            {
                ReaderWriterLockSlimEx.EnterWriteLock( m_LockThreadEventPartitionSpaceNode );
                {
                    m_ThreadEventPartitionSpaceNode -= value;
                }
                ReaderWriterLockSlimEx.ExitWriteLock( m_LockThreadEventPartitionSpaceNode );
            }
        }
        #endregion

        #region zh-CHS ActivateMapSpaceNode事件 | en Public Event
        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private EventHandler<ActivateSpaceNodeEventArgs> m_ThreadEventActivateSpaceNode;
        /// <summary>
        /// 
        /// </summary>
        private ReaderWriterLockSlim m_LockThreadEventActivateSpaceNode = new ReaderWriterLockSlim();
        #endregion
        /// <summary>
        /// 
        /// </summary>
        private event EventHandler<ActivateSpaceNodeEventArgs> ThreadActivateSpaceNode
        {
            add
            {
                ReaderWriterLockSlimEx.EnterWriteLock( m_LockThreadEventActivateSpaceNode );
                {
                    m_ThreadEventActivateSpaceNode += value;
                }
                ReaderWriterLockSlimEx.ExitWriteLock( m_LockThreadEventActivateSpaceNode );
            }
            remove
            {
                ReaderWriterLockSlimEx.EnterWriteLock( m_LockThreadEventActivateSpaceNode );
                {
                    m_ThreadEventActivateSpaceNode -= value;
                }
                ReaderWriterLockSlimEx.ExitWriteLock( m_LockThreadEventActivateSpaceNode );
            }
        }
        #endregion

        #region zh-CHS DeactivateMapSpaceNode事件 | en Public Event
        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private EventHandler<DeactivateSpaceNodeEventArgs> m_ThreadEventDeactivateSpaceNode;
        /// <summary>
        /// 
        /// </summary>
        private ReaderWriterLockSlim m_LockThreadEventDeactivateSpaceNode = new ReaderWriterLockSlim();
        #endregion
        /// <summary>
        /// 
        /// </summary>
        private event EventHandler<DeactivateSpaceNodeEventArgs> ThreadDeactivateSpaceNode
        {
            add
            {
                ReaderWriterLockSlimEx.EnterWriteLock( m_LockThreadEventDeactivateSpaceNode );
                {
                    m_ThreadEventDeactivateSpaceNode += value;
                }
                ReaderWriterLockSlimEx.ExitWriteLock( m_LockThreadEventDeactivateSpaceNode );
            }
            remove
            {
                ReaderWriterLockSlimEx.EnterWriteLock( m_LockThreadEventDeactivateSpaceNode );
                {
                    m_ThreadEventDeactivateSpaceNode -= value;
                }
                ReaderWriterLockSlimEx.ExitWriteLock( m_LockThreadEventDeactivateSpaceNode );
            }
        }
        #endregion

        #endregion

        #region zh-CHS 共有事件 | en Public Event

        #region zh-CHS ItemEnterSpaceNode事件 | en Public Event
        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private EventHandler<ItemEnterSpaceNodeEventArgs> m_ThreadEventItemEnterSpaceNode;
        /// <summary>
        /// 
        /// </summary>
        private ReaderWriterLockSlim m_LockThreadEventItemEnterSpaceNode = new ReaderWriterLockSlim();
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public event EventHandler<ItemEnterSpaceNodeEventArgs> ThreadItemEnterSpaceNode
        {
            add
            {
                ReaderWriterLockSlimEx.EnterWriteLock( m_LockThreadEventItemEnterSpaceNode );
                {
                    m_ThreadEventItemEnterSpaceNode += value;
                }
                ReaderWriterLockSlimEx.ExitWriteLock( m_LockThreadEventItemEnterSpaceNode );
            }
            remove
            {
                ReaderWriterLockSlimEx.EnterWriteLock( m_LockThreadEventItemEnterSpaceNode );
                {
                    m_ThreadEventItemEnterSpaceNode -= value;
                }
                ReaderWriterLockSlimEx.ExitWriteLock( m_LockThreadEventItemEnterSpaceNode );
            }
        }
        #endregion

        #region zh-CHS ItemLeaveSpaceNode事件 | en Public Event
        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private EventHandler<ItemLeaveSpaceNodeEventArgs> m_ThreadEventItemLeaveSpaceNode;
        /// <summary>
        /// 
        /// </summary>
        private ReaderWriterLockSlim m_LockThreadEventItemLeaveSpaceNode = new ReaderWriterLockSlim();
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public event EventHandler<ItemLeaveSpaceNodeEventArgs> ThreadItemLeaveSpaceNode
        {
            add
            {
                ReaderWriterLockSlimEx.EnterWriteLock( m_LockThreadEventItemLeaveSpaceNode );
                {
                    m_ThreadEventItemLeaveSpaceNode += value;
                }
                ReaderWriterLockSlimEx.ExitWriteLock( m_LockThreadEventItemLeaveSpaceNode );
            }
            remove
            {
                ReaderWriterLockSlimEx.EnterWriteLock( m_LockThreadEventItemLeaveSpaceNode );
                {
                    m_ThreadEventItemLeaveSpaceNode -= value;
                }
                ReaderWriterLockSlimEx.ExitWriteLock( m_LockThreadEventItemLeaveSpaceNode );
            }
        }
        #endregion

        #region zh-CHS CreatureEnterSpaceNode事件 | en Public Event
        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private EventHandler<CreatureEnterSpaceNodeEventArgs> m_ThreadEventCreatureEnterSpaceNode;
        /// <summary>
        /// 
        /// </summary>
        private ReaderWriterLockSlim m_LockThreadEventCreatureEnterSpaceNode = new ReaderWriterLockSlim();
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public event EventHandler<CreatureEnterSpaceNodeEventArgs> ThreadCreatureEnterSpaceNode
        {
            add
            {
                ReaderWriterLockSlimEx.EnterWriteLock( m_LockThreadEventCreatureEnterSpaceNode );
                {
                    m_ThreadEventCreatureEnterSpaceNode += value;
                }
                ReaderWriterLockSlimEx.ExitWriteLock( m_LockThreadEventCreatureEnterSpaceNode );
            }
            remove
            {
                ReaderWriterLockSlimEx.EnterWriteLock( m_LockThreadEventCreatureEnterSpaceNode );
                {
                    m_ThreadEventCreatureEnterSpaceNode -= value;
                }
                ReaderWriterLockSlimEx.ExitWriteLock( m_LockThreadEventCreatureEnterSpaceNode );
            }
        }
        #endregion

        #region zh-CHS CreatureLeaveSpaceNode事件 | en Public Event
        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private EventHandler<CreatureLeaveSpaceNodeEventArgs> m_ThreadEventCreatureLeaveSpaceNode;
        /// <summary>
        /// 
        /// </summary>
        private ReaderWriterLockSlim m_LockThreadEventCreatureLeaveSpaceNode = new ReaderWriterLockSlim();
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public event EventHandler<CreatureLeaveSpaceNodeEventArgs> ThreadCreatureLeaveSpaceNode
        {
            add
            {
                ReaderWriterLockSlimEx.EnterWriteLock( m_LockThreadEventCreatureLeaveSpaceNode );
                {
                    m_ThreadEventCreatureLeaveSpaceNode += value;
                }
                ReaderWriterLockSlimEx.ExitWriteLock( m_LockThreadEventCreatureLeaveSpaceNode );
            }
            remove
            {
                ReaderWriterLockSlimEx.EnterWriteLock( m_LockThreadEventCreatureLeaveSpaceNode );
                {
                    m_ThreadEventCreatureLeaveSpaceNode -= value;
                }
                ReaderWriterLockSlimEx.ExitWriteLock( m_LockThreadEventCreatureLeaveSpaceNode );
            }
        }
        #endregion

        #region zh-CHS CharacterEnterSpaceNode事件 | en Public Event
        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private EventHandler<CharacterEnterSpaceNodeEventArgs> m_ThreadEventCharacterEnterSpaceNode;
        /// <summary>
        /// 
        /// </summary>
        private ReaderWriterLockSlim m_LockThreadEventCharacterEnterSpaceNode = new ReaderWriterLockSlim();
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public event EventHandler<CharacterEnterSpaceNodeEventArgs> ThreadCharacterEnterSpaceNode
        {
            add
            {
                ReaderWriterLockSlimEx.EnterWriteLock( m_LockThreadEventCharacterEnterSpaceNode );
                {
                    m_ThreadEventCharacterEnterSpaceNode += value;
                }
                ReaderWriterLockSlimEx.ExitWriteLock( m_LockThreadEventCharacterEnterSpaceNode );
            }
            remove
            {
                ReaderWriterLockSlimEx.EnterWriteLock( m_LockThreadEventCharacterEnterSpaceNode );
                {
                    m_ThreadEventCharacterEnterSpaceNode -= value;
                }
                ReaderWriterLockSlimEx.ExitWriteLock( m_LockThreadEventCharacterEnterSpaceNode );
            }
        }
        #endregion

        #region zh-CHS CharacterLeaveSpaceNode事件 | en Public Event
        #region zh-CHS 私有成员变量 | en Private Member Variables
        /// <summary>
        /// 
        /// </summary>
        private EventHandler<CharacterLeaveSpaceNodeEventArgs> m_ThreadEventCharacterLeaveSpaceNode;
        /// <summary>
        /// 
        /// </summary>
        private ReaderWriterLockSlim m_LockThreadEventCharacterLeaveSpaceNode = new ReaderWriterLockSlim();
        #endregion
        /// <summary>
        /// 
        /// </summary>
        public event EventHandler<CharacterLeaveSpaceNodeEventArgs> ThreadCharacterLeaveSpaceNode
        {
            add
            {
                ReaderWriterLockSlimEx.EnterWriteLock( m_LockThreadEventCharacterLeaveSpaceNode );
                {
                    m_ThreadEventCharacterLeaveSpaceNode += value;
                }
                ReaderWriterLockSlimEx.ExitWriteLock( m_LockThreadEventCharacterLeaveSpaceNode );
            }
            remove
            {
                ReaderWriterLockSlimEx.EnterWriteLock( m_LockThreadEventCharacterLeaveSpaceNode );
                {
                    m_ThreadEventCharacterLeaveSpaceNode -= value;
                }
                ReaderWriterLockSlimEx.ExitWriteLock( m_LockThreadEventCharacterLeaveSpaceNode );
            }
        }
        #endregion

        #endregion
    }
}
#endregion

